﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace FourKill.Engine
{
    public class SpriteSheet3By4 : BaseSpriteSheet
    {
        private const int X_STEP_LEFT_FOOT = 0, X_STILL = 1, X_STEP_RIGHT_FOOT = 2;
        private const int Y_FORWARD = 0, Y_LEFT = 1, Y_RIGHT = 2, Y_BACK = 3;

        public SpriteSheet3By4(Bitmap sheetImage, int columns, int rows)
            : base(sheetImage, columns, rows) {}

        public SpriteSheet3By4(Bitmap sheetImage, int columns, int rows, Color transparentColor)
            : base(sheetImage, columns, rows, transparentColor) { }

        public override int GetFrameCount(SpriteState state)
        {
            return state == SpriteState.StandingStill ? 1 :  3;
        }

        public override Bitmap GetImage(double angle, int index, SpriteState state)
        {
            SpriteDirection dir = Determine4WayDirection(angle);
            return this[
                ((state == SpriteState.StandingStill || state == SpriteState.FloatingStill) ? X_STILL : index),
                (dir == SpriteDirection.Front ? Y_FORWARD :
                    (dir == SpriteDirection.Back ? Y_BACK :
                        (dir == SpriteDirection.Left ? Y_LEFT : Y_RIGHT)))];
        }
    }
}
